package com.wr.service.admin.controller;

import com.wr.service.admin.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/redis")
public class RedisController {
    @Autowired
    private RedisService redisService;

    @PostMapping("/put")
    public String put(String key,String value,long seconds){
        redisService.put(key,value,seconds);
        return "ok";
    }


    @GetMapping("/get")
    public String get(String key){
        Object value = redisService.get(key);
        if (value!=null){
            String json = String.valueOf(value);
            return json;
        }
        return null;
    }
}
